﻿
namespace DBCore
{
    public class Common
    {
        public static EnvironmentType Environment = EnvironmentType.WEB;
        public static string RootPath = "/";
        public static string MapPath(string path)
        {
            if (Environment == EnvironmentType.WEB)
            {
                return System.Web.HttpContext.Current.Server.MapPath(path);
            }
            else
            {
                return System.Web.HttpContext.Current.Server.MapPath("~/"+path);
            }
        }
        static Common()
        {
            var p = System.Diagnostics.Process.GetCurrentProcess();
            if (p.ProcessName == "w3wp" || p.ProcessName.StartsWith("WebDev.WebServer") || p.ProcessName == "iisexpress")
            {
                Environment = EnvironmentType.WEB;
                RootPath = System.Web.HttpContext.Current.Server.MapPath("~/");
            }
            else
            {
                Environment = EnvironmentType.DESKTOP;
                RootPath = System.Environment.CurrentDirectory;
            }
        }
    }





    public enum EnvironmentType
    {
        WEB = 0,
        DESKTOP = 1
    }
}
